package com.jiangyg.mall.session;

import com.jiangyg.mall.core.support.env.EnvConstant;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;

/**
 * 类描述：会话配置
 *
 * @author jiangyg
 * @date 2021-12-26
 */
@Configuration
public class SessionAutoConfiguration {

    @Bean
    public CookieSerializer cookieSerializer() {
        DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer();
        // 设置 Cookie 的域名，放大作用域
        cookieSerializer.setDomainName(EnvConstant.getString("spring.session.domain-name"));
        // 设置 Cookie 名称
        cookieSerializer.setCookieName(EnvConstant.getString("spring.session.cookie-name"));
        return cookieSerializer;
    }

}
